/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.transas.zorlog.data;

/**
 * Data serie implementation of TimeSource interface.
 * @author amalikov
 */
public class TimeSourceFromData extends TimeSource {
	
	public TimeSourceFromData(double[] values, double scale, TimeFormatter formatter, float playbackRate) {
		super(formatter, playbackRate);
		this.scale = scale;
		this.values = values;
	}
	
	public TimeSourceFromData(double[] values, double scale, TimeFormatter formatter) {
		this(values, scale, formatter, 0.05f);
	}

	@Override
	public double getValue(int index) {
		return ((index < values.length) ? values[index] : values[values.length - 1]) * scale;
	}

	private final double[] values;
	private final double scale;
}
